import { useNuxtApp } from "#app";
import { setToken } from "../api/utils/Token";
export const getCodeImg = async (id) => {
  const { $httpRequest } = useNuxtApp(); // 同样获取 $httpRequest
  return await $httpRequest.GET("/captchaImage");
};

export const Login = async (username, password) => {
  const { $httpRequest } = useNuxtApp(); // 同样获取 $httpRequest
  const res = await $httpRequest.POST("/app/login", { username, password });
  const { code, token } = res;
  if (code == 200 && token) {
    setToken(token);
  }
  return res;
};
